package com.chenxys.algorithm.newbie;

/**
 * <p>
 *      打印一个整数的32位二进制
 * </p>
 *
 * @author Chenxys
 * @version V1.0
 * @Package com.chenxys.algorithm
 * @date 12/24/23 4:03 PM
 * @Copyright ©
 */
public class Print32 {
    /**
     * <p>
     *     将1左移i位，与原数相与，得到原数第i位的数值
     * </p>
     * @param num 待打印整数
     */
    public static void print(int num){
        for (int i = 31; i >= 0; i--) {
            System.out.print(((num & (1 << i)) == 0 ? "0" : "1"));
        }
        System.out.println();
    }

    public static void main(String[] args){
        int a = 5;
        print(a);
    }
}
